<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>订单详情</title>
    <link rel="stylesheet" type="text/css" href="../../lib/pagination/style/pagination.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/base.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/news/center.css"/>
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <script type="text/javascript" src="../../js/news/jquery-1.9.1.js"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="../../js/news/page.js"></script>
    <script src="../../js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../lib/layer/layer.js?20201106"></script>
    <script src="../../lib/laydate/laydate.js"></script>
    <style>
        * {font-family: "Microsoft Yahei" !important;}
        b{
            color: red;
        }
        .head_title{
            margin-top: 10px;
            height: 40px;
            position: relative;
        }
        .head_title .title{
            margin-left: 22px;
        }
        .head_title span{
            float: none;
            /*margin-top: 9px;*/
            font-size: 22px;
            color: #333;
            display: inline-block;
            margin-left: 10px;
            vertical-align: middle;
            margin-top: -6px;
        }
        .saveBtn{
            display: block;
            float: left;
            background: url(../img/confirm.png) no-repeat;
            border: none;
            width: 70px;
            height: 29px;
            line-height: 29px;
            margin-left: 10px;
            cursor: pointer;
        }
        .resetBtn {
            display: block;
            float: left;
            background: url(../img/news/new_filling.png) no-repeat;
            border: none;
            width: 70px;
            height: 29px;
            line-height: 29px;
            margin-left: 10px;
            cursor: pointer;
        }
        .div_Btn{
            position: absolute;
            left:45% ;
            margin: 10px auto;
        }
        select{
            width: 250px;
            height: 30px;
        }
        .newTbale tr td {
            border-right: #ccc 1px solid;
            padding: 5px 30px;
        }
        input[type="text"]{
            width: 250px;
            height: 30px;
        }
        .newTbale {
            width: 85%;
            margin: 0px auto;
        }
        table {
            border-collapse: collapse;
            border-spacing: 0;
        }
        #pagediv{
            position: relative;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
</head>
<body>
<!--head开始-->
<div class="head_title">
    <div class="title">
        <img src="/img/commonTheme/${sessionScope.InterfaceModel}/flow_run_title.png"><span style="">订单详情</span>
    </div>
</div>
<div id="pagediv">
    <form id="ajaxforms" action="/order/addOrders">
        <table class="newTbale">
            <tr>
                <td>订单编号:</td>
                <td><input type="text" name="orderNo" readonly="readonly" disabled="true"/></td>
                <td>订单名称:</td>
                <td><input type="text" readonly="readonly" name="orderName" disabled="true"/><b>*</b></td>
            </tr>
            <tr>
                <td>客户名称:</td>
                <td><input readonly="readonly" disabled="true" type="text"  id="customerName" name="customerName"   />&nbsp;&nbsp;
                <%--<input type="text" id="customerName" hidden="false" />--%>
                <input type="hidden" id="customerId" name="customerId"  />
                    <td>订单状态:</td>
                    <td>
                        <select name="status" disabled="true" readonly="readonly">
                        <option value="">选择订单状态</option>
                        <option value="0">下单</option>
                        <option value="1">发货</option>
                        <option value="2">完成</option>
                        </select>
                        <b>*</b>
                    </td>
            </tr>
            <tr>
                <td>订单类型:</td>
                <td>
                    <select name="type" disabled="true"  readonly="readonly">
                        <option value="">选择订单类型</option>
                        <option value="0">订货单</option>
                        <option value="1">发货单</option>
                        <option value="2">收货单</option>
                    </select>
                    <b>*</b>
                </td>
                <td>订单总金额:</td>
                <td>
                    <input type="text" name="total" readonly="readonly" disabled="true"/>
                </td>
            </tr>
            <tr>
                <td>货币单位:</td>
                <td>
                    <select name="monetaryUnit" disabled="true" readonly="readonly">
                        <option value="">选择货币单位</option>
                    </select>
                    <b>*</b>
                </td>
                <td>付款方式:</td>
                <td>
                    <select name="payWay" disabled="true" readonly="readonly">
                        <option value="">选择付款方式</option>
                    </select>
                    <b>*</b>
                </td>
            </tr>
            <tr>
                <td>合同名称:</td>
                <td><input type="text" name="contractName" readonly="readonly" disabled="true"/></td>

                <td>创建人:</td>
                <td><input type="text" name="creator" readonly="readonly" disabled="true"/></td>
            </tr>
            <tr>
                <td>创建时间:</td>
                <td><input type="text" name="createTime" readonly="readonly" disabled="true"/></td>

                </tr>
        </table>
    </form>
    <div class="div_Btn">
        <div class="resetBtn" onclick="javascript:window.location.href='/order/orderIndex';">
            <span  style="margin-left: 32px;" >返回</span>
        </div>
    </div>
</div>
</body>
<script>
    var getRequestObj=$.GetRequest();
    function GetDropDownBox(fn) {
        //select 根据ajax绑定数据 循环显示
        $.ajax({
            url: "/order/selectMonetaryUnit",
            type:'get',
            async:false,
            dataType:"JSON",
            success:function(data){
                var str='<option value="">请选择货币单位</option>';
                for (var i=0;i<data.obj.length;i++){
                    str += '<option value="'+data.obj[i].codeNo+'">'+data.obj[i].codeName+'</option>'
                }
                $('[name="monetaryUnit"]').html(str);
            }
        })

        $.ajax({
            url: "/order/selectByPayment",
            type:'get',
            dataType:"JSON",
            async:false,
            success:function(data){
                var str='<option value="">请选择付款方式</option>';
                for (var i=0;i<data.obj.length;i++){
                    str += '<option value="'+data.obj[i].codeNo+'">'+data.obj[i].codeName+'</option>'
                }
                $('[name="payWay"]').html(str);
            }
        })

    }
    function  ajaxforms() {
        if($('[name="status"] option:selected').val() == ''){
            layer.msg('请输入订单状态 ！',{icon:6});
        }else if($('[name="type"] option:selected').val() == ''){
            layer.msg('请选择订单类型！',{icon:2});
        }else if($('[name="monetaryUnit"] option:selected').val() == ''){
            layer.msg('请选择货币单位！',{icon:2});
        }else if($('[name="payWay"] option:selected').val() == ''){
            layer.msg('请选择付款方式！',{icon:2});
        }else {
            $.ajax({
                url: '/order/updateByPrimaryKey',
                type: 'post',
                dataType: 'json',
                data: $('#ajaxforms').serialize()+'&orderId='+getRequestObj.orderId,
                success: function (data) {
                    if(data.flag){
                        /*alert("修改成功！");
                         location.reload();*/
                        layer.msg('修改成功！',{icon:1},function () {
                            window.close();
                            window.location.href='/order/orderIndex'
                        });/*添加成功*/
                    }else{
                        alert("修改失败！");
                    }
                },
                error: function (data) {
                    alert("修改失败！");
                }
            })
        }
    }

    //数据回显
    $(function () {
        GetDropDownBox(function(){
            $('[name="monetaryUnit"]').val(getRequestObj.codeNo);
            $('[name="payWay"]').val(getRequestObj.codeNo);
        });
        $.ajax({
            url:'/order/selectOrderById',
            data:{
                orderId:getRequestObj.orderId
            },
            async:false,
            type: 'get',
            dataType: 'json',
            success:function (json) {

                if (json.flag) {
                    $('[name="orderNo"]').val(json.object.orderNo);
                    $('[name="orderName"]').val(json.object.orderName);
                    $('[name="customerName"]').val(json.object.customerName);
                    $('[name="status"]').val(json.object.status);
                    $('[name="type"]').val(json.object.type);
                    $('[name="total"]').val(json.object.total);
                    $('[name="monetaryUnit"]').val(json.object.monetaryUnit);
                    $('[name="payWay"]').val(json.object.payWay);
                    $('[name="contractName"]').val(json.object.contractName);
                    $('[name="creator"]').val(json.object.creator);
                    $('[name="createTime"]').val(json.object.createTime);
                } else {
                    $.layerMsg({content: '网络错误！', icon: 2});
                }
            }
        })
    })

</script>

</html>
